/**Request class
 * 
 * @author locphan
 * @version 1.01
 */
import java.util.Calendar;

public class Request implements Comparable
{
   private int seats; 
   private String event;
   private String name;
   private int duration;
   private Calendar date;
   private int startingtime;
   private String[] months = {
         "Jan", "Feb", "Mar", "Apr",
         "May", "Jun", "Jul", "Aug",
         "Sep", "Oct", "Nov", "Dec" };
   
   /**Contructs a request
    * 
    * @param name Name of host
    * @param event Name of event
    * @param date Date of event
    * @param startingtime Starting Time
    * @param aduration Duration
    * @param seats Seats
    */
   public Request(String name, String event,Calendar date,int startingtime, int aduration, int seats) 
   {
      this.name = name;
      this.event = event;
      this.date = date;
      this.duration = aduration;
      this.seats = seats;
      this.startingtime = startingtime;
   }
   /**Returns name of the event
    * 
    * @return name of event
    */
   public String getEvent()
   {
      return event;
   }
   /**Returns date of the event
    * 
    * @return date
    */
   public Calendar getDate()
   {
      return date;
   }
   /**Returns duration
    * 
    * @return duration
    */
   public int getDuration()
   {
      return duration;
   }
   /**Returns starting time
    * 
    * @return starting time
    */
   public int getStartingTime()
   {
      return startingtime;
   }
   /**Returns ending time
    * 
    * @return ending time
    */
   public double getEndTime()
   {
      return startingtime+(duration/60);
   }
   /**Returns number of seats needed
    * 
    * @return seats
    */
   public int getSeats()
   {
      return seats;
   }
   /**Returns name of the host
    * 
    * @return host
    */
   public String getName()
   {
      return name;
   }
   /**
    * Returns a representation of this request
    */
   public String toString()
   {
      return name+";"+event+";"+date.get(Calendar.YEAR)+";"+months[date.get(Calendar.MONTH)]+";"+date.get(Calendar.DAY_OF_MONTH)
         + ";"+this.startingtime+";"+this.duration+";"+this.seats;
   }
   /**
    * Compares with other request
    */
   public int compareTo(Object o)
   {
      if(!(o instanceof Request))
         throw new ClassCastException("Request Object expected.");
      
      Request request = (Request)o;
      
      double time1 = this.getStartingTime();
      double time2 = request.getStartingTime();
      
      if(this.getDate().compareTo(request.getDate())==0)
      {
         return (int) (time1-time2);
      }
      else
      {
         return this.getDate().compareTo(request.getDate());
      }
           
   }
   
}
